package vn.edu.hut.soict.translate.dictionary.bilingual;

import java.util.ArrayList;
import java.util.List;

import vn.edu.hut.soict.translate.dictionary.Dictionary;

public class BilingualDictionary extends Dictionary<String, String> {
	private static final char CROSS_REFERENCE_SIGN = '$';
	public static final String DICTIONARY_FILE = "res/dictionary/VEdictionary.txt";

	protected void addEntry(String word, String content) {
		super.addEntry(word, content);
	}

	public List<String> meaning(String word) {
		List<String> meanings = new ArrayList<String>();
		List<String> lookUpResults = lookUp(word);
		if (lookUpResults == null) {
			return null;
		}
		for (String result : lookUpResults) {
			if (result.charAt(0) != CROSS_REFERENCE_SIGN) {
				meanings.add(result);
			}
			else {
				String crossRef = result.substring(1).replace('_', ' ');
				meanings.addAll(meaning(crossRef));
			}
		}
		return meanings;
	}
}
